class NewsController < ApplicationController
  before_filter :login_required, :only => [ :new, :edit, :destroy ]
  
  def index
    @news = Page.all_news
    redirect_to news_path(@news.first)
  end
  
  def new
    @page = Page.new
  end
  
  def edit
    @page = Page.find(params[:id])
  end
  
  def show
    @news = Page.find(params[:id])
    @latest_news = Page.find(:all, :conditions => [ "section_id = ?", Section.find_by_name("news").id ], :limit => 6, :order => "created_at DESC")
  end
  
  def destroy
    Page.find(params[:id]).destroy
    redirect_to news_path(Page.find(:first, :conditions => [ "section_id = ?", Section.find_by_name("news").id ]))
  end
  
end